import Vue from "vue";
import Router from "vue-router";
import { routerMode } from "@/utils/env";

Vue.use(Router);

/* Layout */
import Layout from "../views/layout/Layout";
import layer from "../views/layer/index";
// 静态路由
export const constantRouterMap = [{
        path: "/login",
        component: () =>
            import ("@/views/login/index"),
        hidden: true //当设置 true 的时候该路由不会再侧边栏出现 如401，login等页面(默认 false)
    },
    {
        path: "/404",
        component: () =>
            import ("@/views/error/404"),
        hidden: true
    },
    {
        path: "/",
        redirect: "/home",
        hidden: true
    },
    {
        path: "/",
        component: Layout,
        redirect: "/home",
        name: "home",
        hidden: true,
        children: [{
            path: "home",
            component: () =>
                import ("@/views/home/index")
        }]
    },
];

export default new Router({
    // mode: routerMode,
    scrollBehavior: () => ({
        y: 0
    }),
    routes: constantRouterMap
});
// 自定义动态异步路由
export const asyncRouterMap = [{
    path: '/sell_goods',
    component: Layout,
    redirect: '/home',
    name: 'sell_goods',
    hidden: false,
    children: [{
        path: 'list',
        'keepalive': false,
        component: () =>
            import ('@/views/sell_goods/index'),
        name: 'list',
        meta: {
            title: '出售中的商品',
            icon: 'practice'
        }
    }]
}, {
    path: '/order',
    component: Layout,
    redirect: '/home',
    name: 'order',
    hidden: false,
    children: [{
        path: 'list',
        'keepalive': false,
        component: () =>
            import ('@/views/order/index'),
        name: 'list',
        meta: {
            title: '订单管理',
            icon: 'practice'
        }
    }]
}, ];